const { transformSync } = require('@babel/core')

const code = `
  console.log('babel');
  if (DEBUG) {
    const a = 1
    const b = 2
    console.log(a + b)
  }
`

const babelPlugin = {
  plugins: ['./myBabel.js']
}

const output = transformSync(code, babelPlugin) // 第二个参数option就是.babelrc中的配置  -->  抽象语法树ast

console.log(output.code)
